/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ControlLayer;

import DBLayer.DBProduct;
import ModelLayer.Car;
import ModelLayer.CarColor;
import ModelLayer.CarEngine;
import ModelLayer.Product;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Moulde
 */
public class ProductController
{
    DBProduct dbProduct;

    public ProductController()
    {
        dbProduct = new DBProduct();
    }

    public ArrayList<Product> getProducts()
    {
        return new ArrayList<Product>();// dbProduct.getProducts();
    }

    public ArrayList<Car> getProductsInStock()
    {
        DBProduct DBP = new DBProduct();
        String query = "Select * From Car, Product Where Product.ProductID = Car.ProductID";
        //String query = "Select Year, Brand, Model, Doors, PurchasePrice From Car, Product Where Product.ProductID = Car.ProductID";

        return DBP.getProductsCar(query);
    }

    public ArrayList<Car> getProducts(String supplier)
    {
        supplier = supplier.toLowerCase();
        DBProduct DBP = new DBProduct();
        String query;

        if(supplier.equals("opel"))
        {
            query = "Select CarID as ID, Make as Brand, Model, Price, Doors, Year From CarOpel";
            return DBP.getProductsCar(query);
        }
        else if(supplier.equals("kia"))
        {
            System.out.println("Kia er valgt!!");
        }
        else if(supplier.equals("saab"))
        {
            System.out.println("Saab er valgt!!");
        }
        else if(supplier.equals("caddilac"))
        {
            System.out.println("Caddilac er valgt!!");
        }
        else
        {
            System.out.println("Fejl");
        }

        return new ArrayList<Car>();
    }

    public ArrayList<CarEngine> getCarEngine()
    {
        return dbProduct.getCarEngine();
    }

    public ArrayList<CarColor> getCarColor()
    {
        return dbProduct.getCarColor();
    }

    public List<Integer> getDistinctCarYears()
    {
        return dbProduct.getDistinctCarYears();
    }
}
